package com.ruoyi.electronicFence.service.Impl;


import com.ruoyi.electronicFence.domain.TEfAreaApe;
import com.ruoyi.electronicFence.domain.TEfFenceArea;
import com.ruoyi.electronicFence.mapper.TEfAreaApeMapper;
import com.ruoyi.electronicFence.mapper.TEfFenceAreaMapper;
import com.ruoyi.electronicFence.service.ITEfFenceAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 围栏区域信息Service业务层处理
 *
 * @author ruoyi
 * @date 2024-04-08
 */
@Service
public class TEfFenceAreaServiceImpl implements ITEfFenceAreaService
{
    @Autowired
    private TEfFenceAreaMapper tEfFenceAreaMapper;

    @Autowired
    private TEfAreaApeMapper tEfAreaApeMapper;

    /**
     * 查询围栏区域信息
     *
     * @param id 围栏区域信息主键
     * @return 围栏区域信息
     */
    @Override
    public TEfFenceArea selectTEfFenceAreaById(Long id)
    {
        return tEfFenceAreaMapper.selectTEfFenceAreaById(id);
    }

    /**
     * 查询围栏区域信息列表
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 围栏区域信息
     */
    @Override
    public List<TEfFenceArea> selectTEfFenceAreaList(TEfFenceArea tEfFenceArea)
    {
        return tEfFenceAreaMapper.selectTEfFenceAreaList(tEfFenceArea);
    }

    /**
     * 查询围栏区域信息列表
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 围栏区域信息
     */
    @Override
    public Long selectTEfFenceAreaListTotal(TEfFenceArea tEfFenceArea)
    {
        return tEfFenceAreaMapper.selectTEfFenceAreaListTotal(tEfFenceArea);
    }

    /**
     * 查询围栏区域信息列表
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 围栏区域信息
     */
    @Override
    public List<TEfFenceArea> selectTEfFenceAreaDetailsList(TEfFenceArea tEfFenceArea)
    {
        return tEfFenceAreaMapper.selectTEfFenceAreaDetailsList(tEfFenceArea);
    }

    /**
     * 查询围栏区域信息列表
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 围栏区域信息
     */
    @Override
    public List<TEfFenceArea> selectTEfFenceAreaDetailsList2(TEfFenceArea tEfFenceArea)
    {
        return tEfFenceAreaMapper.selectTEfFenceAreaDetailsList2(tEfFenceArea);
    }

    @Override
    public List<TEfFenceArea> selectAreaAndEquipmentList(TEfFenceArea tEfFenceArea) {
        return tEfFenceAreaMapper.selectAreaAndEquipmentList(tEfFenceArea);
    }

    /**
     * 新增围栏区域信息
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 结果
     */
    @Override
    public int insertTEfFenceArea(TEfFenceArea tEfFenceArea)
    {
        return tEfFenceAreaMapper.insertTEfFenceArea(tEfFenceArea);
    }

    /**
     * 新增围栏区域信息
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 结果
     */
    @Override
    public int detailsInsertTEfFenceArea(TEfFenceArea tEfFenceArea)
    {
        List<TEfAreaApe> tEfAreaApes = tEfFenceArea.getTEfAreaApes();
        tEfAreaApeMapper.insertBatchTEfAreaApe( tEfAreaApes);
        return tEfFenceAreaMapper.insertTEfFenceArea(tEfFenceArea);
    }
    /**
     * 修改围栏区域信息
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 结果
     */
    @Override
    public int updateTEfFenceArea(TEfFenceArea tEfFenceArea)
    {

        return tEfFenceAreaMapper.updateTEfFenceArea(tEfFenceArea);
    }

    /**
     * 修改围栏区域详情信息
     *
     * @param tEfFenceArea 围栏区域信息
     * @return 结果
     */
    @Override
    public int detailsUpdateTEfFenceArea(TEfFenceArea tEfFenceArea)
    {
        List<TEfAreaApe> tEfAreaApes = tEfFenceArea.getTEfAreaApes();
        tEfAreaApeMapper.updateBatchTEfAreaApe( tEfAreaApes);
        return tEfFenceAreaMapper.updateTEfFenceArea(tEfFenceArea);
    }

    /**
     * 批量删除围栏区域信息
     *
     * @param ids 需要删除的围栏区域信息主键
     * @return 结果
     */
    @Override
    public int deleteTEfFenceAreaByIds(Long[] ids)
    {
        return tEfFenceAreaMapper.deleteTEfFenceAreaByIds(ids);
    }

    /**
     * 批量删除围栏区域信息
     *
     * @param
     * @return 结果
     */
    @Override
    public int detailsDeleteTEfFenceAreaByIds(TEfFenceArea tEfFenceArea)
    {
        List<TEfAreaApe> tEfAreaApes = tEfFenceArea.getTEfAreaApes();
        tEfAreaApeMapper.deleteBatchTEfAreaApeById(tEfAreaApes);
        return tEfFenceAreaMapper.deleteTEfFenceAreaById(tEfFenceArea.getId());
    }


    /**
     * 删除围栏区域信息信息
     *
     * @param id 围栏区域信息主键
     * @return 结果
     */
    @Override
    public int deleteTEfFenceAreaById(Long id)
    {
        return tEfFenceAreaMapper.deleteTEfFenceAreaById(id);
    }
}
